package sv.view;

import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import sv.main.*;

public class PrebScreen extends JFrame {
	
	private JButton startServer;
	private JButton connect;
	private MousePrebAdapter mouse;
	private JTextField serverAddress;
	private MyNetwork connection;
	private Game game;
	private JTextArea log;
	
	public PrebScreen(MyNetwork connection, Game oGame, JTextArea log, String message){
		super(message);
		this.connection = connection;
		this.game = oGame;
		this.log = log;
		setLocation(60, 100);
		setSize(200, 200);
		setResizable(false);
		
		if (message == "Preparations"){
			serverAddress = new JTextField("server address");
		}
		else {
			serverAddress = new JTextField(message);
		}
		serverAddress.setLocation(20, 110);
		serverAddress.setSize(150, 20);
		
		mouse = new MousePrebAdapter(serverAddress, connection, this, game, log);
		
		startServer = new JButton("start as server");
		startServer.setSize(150, 30);
		startServer.setLocation(20,20);
		startServer.addMouseListener(mouse);
		
		connect = new JButton("connect to server");
		connect.setSize(150, 30);
		connect.setLocation(20, 70);
		connect.addMouseListener(mouse);
		
		getContentPane().setLayout(null);
		add(startServer);
		add(serverAddress);
		add(connect);
		
		setVisible(true);
	}

}
